<template>
  <div class="moveMainBox" v-if="isMoveMainBox">
    <div class="mengchen"></div>
    <div class="moveMain">
      <div class="moveTitle">相位</div>
      <div class="moveMeddle">
        <div>正相输入</div>
        <span
          :class="[radioShow ? 'ic_radio_active' : 'ic_radio', 'ic_pat']"
          @click="handlerRadio('正相输入')"
        ></span>
      </div>
      <div class="moveMeddleLine"></div>
      <div class="moveMeddle">
        <div>反相输入</div>
        <span
          :class="[radioShowOne ? 'ic_radio_active' : 'ic_radio', 'ic_pat']"
          @click="handlerRadio('反相输入')"
        ></span>
      </div>
      <div class="moveFoot">
        <span @click="hanlderCancel">取消</span>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from "vuex";
export default {
  props: ["isMoveMainBox"],
  data() {
    return {
      radioShow: false,
      radioShowOne: false,
    };
  },
  created() {
    // console.log("--------------------------99", this.SpeakerMuteReverse);
    // if (this.SpeakerMuteReverse) {
    //   this.radioShow = true;
    //   this.$emit("handlerSpeakerRadio", "正相输入");
    // } else {
    //   this.radioShowOne = true;
    //   this.$emit("handlerSpeakerRadio", "反相输入");
    // }
  },
  computed: {
    ...mapState({
      SpeakerMuteReverse: (state) => state.ble.SpeakerMuteReverse,
      SpeakerVolume: (state) => state.ble.SpeakerVolume,
      loudspeaker: (state) => state.ble.loudspeaker,
    }),
  },
  watch: {
    SpeakerMuteReverse(newV) {
      console.log("--------------------------99", newV);
      if (newV) {
        this.radioShow = true;
        this.radioShowOne = false;
          this.$emit("handlerSpeakerRadio", '正相输入');
      } else {
        this.radioShowOne = true;
        this.radioShow = false;
          this.$emit("handlerSpeakerRadio", '反相输入');
      }
    },
  },
  methods: {
    handlerRadio(val) {
      if (val == "正相输入") {
        this.radioShow = true;
        this.radioShowOne = false;
      
        let str =
          `F05505000D09${this.loudspeaker}00${this.SpeakerVolume.toString(
            16
          ).padStart(2, 0)}` +
          this.$getCheckSum(
            `F05505000D09${this.loudspeaker}00${this.SpeakerVolume.toString(
              16
            ).padStart(2, 0)}`
          );
        console.log("喇叭非静音正---" + str);
        window.bleManage.send(str);
      }
      if (val == "反相输入") {
        this.radioShowOne = true;
        this.radioShow = false;
       
        let str =
          `F05505000D09${this.loudspeaker}01${this.SpeakerVolume.toString(
            16
          ).padStart(2, 0)}` +
          this.$getCheckSum(
            `F05505000D09${this.loudspeaker}01${this.SpeakerVolume.toString(
              16
            ).padStart(2, 0)}`
          );
        console.log("喇叭非静音反---" + str);
        window.bleManage.send(str);
      }

      this.$emit("handlerSpeakerRadio", val);
    },
    hanlderCancel() {
      this.$emit("hanlderCancel");
    },
  },
};
</script>

<style lang="less">
.mengchen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--border);
}
.moveMain {
  position: absolute;
  width: 336px;
  height: 216px;
  //   background: red;
  background-color: var(--box_bg);
  opacity: 1;
  border-radius: 24px;
  left: 50%;
  transform: translate(-50%, 0);
  bottom: 16px;
  padding: 0 24px;
  .moveTitle {
    width: 288px;
    height: 56px;
    line-height: 56px;
    font-size: 20px;
    color: var(--font);
  }
  .moveMeddle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 288px;
    height: 48px;
  }
  .moveMeddleLine {
    height: 1px;
    background: var(--border);
  }
  .moveFoot {
    width: 288px;
    height: 40px;
    margin-top: 8px;
    text-align: center;
    span {
      line-height: 40px;
      font-size: 16px;
      color: var(--color_blue);
    }
  }
}
</style>